<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('编辑基本信息')"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body>
<div class="main-content">
    <form id="form-shopApplet-edit" class="form-horizontal" th:object="${shopApplet}">
        <input name="shopAppletId" type="hidden" th:field="*{id}"/>
        <h4 class="form-header h4">基本信息</h4>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label"><span style="color: red; ">*</span>小程序名称：</label>
                    <div class="col-sm-8">
                        <input id="appletName" name="appletName" placeholder="请输入小程序名称" class="form-control"
                               type="text" maxlength="50" th:value="*{appletName}"
                               disabled>
                        <span class="help-block m-b-none" style="color:red"><i class="fa fa-info-circle"></i>如信息有更新，请联系客服修改</span>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">AppID：</label>
                    <div class="col-sm-8">
                        <input name="appletAppId" placeholder="请输入小程序AppID" class="form-control" type="text"
                               th:value="*{appletAppId}"
                               maxlength="100" disabled>
                        <span class="help-block m-b-none" style="color:red"><i class="fa fa-info-circle"></i>如信息有更新，请联系客服修改</span>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">AppSecret：</label>
                    <div class="col-sm-8">
                        <input name="appletSecret" placeholder="请输入小程序AppSecret" class="form-control" type="text"
                               th:value="*{appletSecret}"
                               maxlength="100" disabled>
                        <span class="help-block m-b-none" style="color:red"><i class="fa fa-info-circle"></i>如信息有更新，请联系客服修改</span>
                    </div>
                </div>
            </div>
        </div>
        <h4 class="form-header h4">支付信息</h4>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">商户号：</label>
                    <div class="col-sm-8">
                        <input name="appletMchId" placeholder="请输入微信支付商户号" class="form-control" type="number"
                               th:value="*{appletMchId}"
                               maxlength="30" disabled>
                        <span class="help-block m-b-none" style="color:red"><i class="fa fa-info-circle"></i>如信息有更新，请联系客服修改</span>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">支付密钥：</label>
                    <div class="col-sm-8">
                        <input name="appletPayKey" placeholder="请输入微信支付密钥" class="form-control" type="text"
                               th:value="*{appletPayKey}"
                               maxlength="100" disabled>
                        <span class="help-block m-b-none" style="color:red"><i class="fa fa-info-circle"></i>如信息有更新，请联系客服修改</span>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<script>
    var prefix = ctx + "back/shopApplet";
    var initData = {
        appletPayCert: $("#appletPayCert").val(),
    };
    $("#form-shopApplet-edit").validate({
        onkeyup: false,
        rules: {
            shopName: {
                minlength: 2,
                maxlength: 20,
                remote: {
                    url: prefix + "/checkShopAppletNameUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        "shopAppletId": $("#shopAppletId").val(),
                        "shopAppletName": function () {
                            return $.common.trim($("#shopAppletName").val());
                        }
                    },
                    dataFilter: function (data, type) {
                        return $.validate.unique(data);
                    }
                }
            }
        },
        messages: {
            "shopAppletName": {
                remote: "小程序名称已被使用"
            },
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-shopApplet-edit").serializeArray();
            $.operate.save(prefix + "/edit", data);
        }
    }
</script>
</body>
</html>